package com.device.repository;

import com.device.entity.UserDevice;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface UserDeviceRepository extends JpaRepository<UserDevice,Integer> {

    List<UserDevice> findByDeviceNameAndAreaAndInstituteNameAndStatus(String deviceName,String area,String instituteName,Boolean status);

    List<UserDevice> findByAreaAndDeviceNameAndStatus(String area,String deviceName,Boolean status);
    Page<UserDevice> findByAreaAndDeviceNameAndStatus(String area,String deviceName,Boolean status,Pageable pageable);

    Page<UserDevice> findByDeviceName(String deviceName,Pageable pageable);

    @Modifying
    @Query("delete from UserDevice ud where ud.id in :deleteIds")
    void deleteByIdInBatch(@Param("deleteIds") List<Integer> deleteIds);

}
